Skip to content

Fix query tab data grid lag with large result sets#28

Merged
datlechin merged 2 commits into
mainfrom
fix/query-tab-datagrid-performance
Feb 6, 2026
Merged

Fix query tab data grid lag with large result sets#28
datlechin merged 2 commits into
mainfrom
fix/query-tab-datagrid-performance

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

  • Refactor InMemoryRowProvider to lazily materialize TableRowData on demand via a cache dictionary, eliminating O(n) heap allocations (e.g. 200k objects) on every SwiftUI body evaluation
  • Add SortedRowsCache in MainEditorContentView keyed by tab ID, sort params, and resultVersion to avoid redundant O(n log n) sorting on every render
  • Fix status bar incorrectly showing pagination range (1-1000 of X rows) for query tabs — now shows formatted total row count (e.g. 200,000 rows)

Test plan

  • Run SELECT id, email, updated_at FROM users (200k rows) — scrolling, clicking rows, and switching tabs should be smooth
  • Click column header to sort — first sort may take a moment, subsequent renders should be instant (cached)
  • Open a table tab, edit cells, add/delete rows — must still work correctly
  • Status bar should show 200,000 rows for query tabs, 1-1000 of 200,000 rows for table tabs
  • Build succeeds with xcodebuild
  • Lint passes with swiftlint lint --strict

InMemoryRowProvider was recreated on every SwiftUI body evaluation,
causing O(n) heap allocations (e.g. 200k TableRowData objects per render).
Client-side sorting also ran O(n log n) on every render when active.

- Refactor InMemoryRowProvider to store QueryResultRow directly and
  create TableRowData lazily via a cache dictionary (~30 visible rows)
- Add SortedRowsCache in MainEditorContentView keyed by tab ID,
  sort params, and resultVersion to avoid redundant sorting
- Fix status bar showing pagination range (1-1000) for query tabs;
  now shows formatted total row count instead
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46e6cd78a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread OpenTable/Views/Main/Child/MainEditorContentView.swift
Increment resultVersion in switchDatabase, OpenTableTabSmart, and
row paste operations so the sort cache doesn't return stale rows.
@datlechin datlechin merged commit e1c2b6e into main Feb 6, 2026
@datlechin datlechin deleted the fix/query-tab-datagrid-performance branch February 6, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant